/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.Memory;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.texture.Texture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.WeakHashMap;

/**
 *
 * @author usuario
 */
public class Materials {
    
    private HashMap<String, WeakHashMap<String, Material>> cache = new HashMap<String, WeakHashMap<String, Material>>();
    //private WeakHashMap<String, Material> Materials = new WeakHashMap<String, Material>();
    
    private WeakHashMap<String, Material> getMatByType(String type) {
        if(!cache.containsKey(type))
            cache.put(type, new WeakHashMap<String, Material>());
        return cache.get(type);
    }
    
    public void addMaterial(String name, String type, Material mat) {
        if(!getMatByType(type).containsKey(name))
            getMatByType(type).put(name, mat);
    }
    
    public Material getMaterial(String name, String type) {
         if( getMatByType(type).containsKey(name))
             return getMatByType(type).get(name);
         else
             return null;
    }
    
}
